import { getEmployeeList } from '@/api/employees'
const state = {
  Employeedata: [],
  Employeetotal: 0
}
const mutations = {
  Set_EmployeeList(state, data) {
    state.Employeedata = data
  },
  Set_EmployeeListtotal(state, total) {
    state.Employeetotal = total
  }
}
const actions = {
  async getEmployeeList(store, data) {
    var { rows, total } = await getEmployeeList(data)
    rows = rows.map(user => {
      const statu = Math.round(Math.random())
      return {
        ...user,
        enableState: Number(user.enableState) || Number(statu)
      }
    })
    await store.commit('Set_EmployeeList', rows)
    await store.commit('Set_EmployeeListtotal', total)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

